<article id="wikiArticle">
<p></p><p></p>
<h2 id="Summary" name="Summary">概述</h2>
<p><font face="Courier New, Andale Mono, monospace">RegExp.prototype 属性表示 </font><span style="line-height: 1.5;"><a href="Reference/Global_Objects/RegExp" title="RegExp 构造函数创建了一个正则表达式对象，用于将文本与一个模式匹配。"><code>RegExp</code></a> </span><span style="font-family: 'Courier New', 'Andale Mono', monospace; line-height: 1.5;">构造函数的原型对象。</span></p>
<h2 id="Description" name="Description">描述</h2>
<p>查看<font face="Courier New, Andale Mono, monospace"> </font><span style="line-height: 1.5;"><a href="Reference/Global_Objects/RegExp" title="RegExp 构造函数创建了一个正则表达式对象，用于将文本与一个模式匹配。"><code>RegExp</code></a> </span><span style="line-height: 1.5;">了解更多关于 </span><code style="font-style: normal; line-height: 1.5;">RegExp</code> <code style="font-style: normal; line-height: 1.5;">实例的说明。</code></p>
<p><code>RegExp</code> 实例继承 <code>RegExp.prototype</code>。修改该原型对象上的属性或方法会影响到所有的 <code>RegExp</code> <code>实例。</code></p>
<h2 id="Properties" name="Properties">属性</h2>
<p>查看<a class="new" href="/zh-CN/docs/JavaScript/Reference/Deprecated_Features#RegExp_Properties" rel="nofollow" title="zh-CN/docs/JavaScript/Reference/Deprecated_Features#RegExp_Properties">已废弃的RegExp属性</a></p>
<p>注意，<code>RegExp</code> 对象的几个属性既有完整的长属性名，也有对应的类 Perl 的短属性名。两个属性都有着同样的值。JavaScript 的正则语法就是基于 Perl 的。</p>
<dl>
<dt>
<code style="font-style: normal; font-weight: bold;">RegExp.prototype.</code><code style="font-style: normal; font-weight: bold;">constructor</code></dt>
<dd>
  创建该正则对象的构造函数。</dd>
<dt>
<a href="Reference/Global_Objects/RegExp/global" title='global 属性表明正则表达式是否使用了 "g" 标志。global 是一个正则表达式实例的只读属性。'><code>RegExp.prototype.global</code></a></dt>
<dd>
  是否开启全局匹配，也就是匹配目标字符串中所有可能的匹配项，而不是只进行第一次匹配。</dd>
<dt>
<a href="Reference/Global_Objects/RegExp/ignoreCase" title='ignoreCase 属性表明正则表达式是否使用了 "i" 标志。ignoreCase 是正则表达式实例的只读属性。'><code>RegExp.prototype.ignoreCase</code></a></dt>
<dd>
  在匹配字符串时是否要忽略字符的大小写。</dd>
<dt>
<a href="Reference/Global_Objects/RegExp/lastIndex" title="lastIndex 是正则表达式的一个可读可写的整型属性，用来指定下一次匹配的起始索引。"><code>RegExp.prototype.lastIndex</code></a></dt>
<dd>
  下次匹配开始的字符串索引位置。</dd>
<dt>
<a href="Reference/Global_Objects/RegExp/multiline" title='multiline 属性表明正则表达式是否使用了 "m" 标志。multiline 是正则表达式实例的一个只读属性。'><code>RegExp.prototype.multiline</code></a></dt>
<dd>
  是否开启多行模式匹配（影响 ^ 和 $ 的行为）。</dd>
<dt>
<a href="Reference/Global_Objects/RegExp/source" title="source 属性返回一个值为当前正则表达式对象的模式文本的字符串，该字符串不会包含正则字面量两边的斜杠以及任何的标志字符。"><code>RegExp.prototype.source</code></a></dt>
<dd>
  正则对象的源模式文本。</dd>
<dt>
<a href="Reference/Global_Objects/RegExp/sticky" title="sticky 属性反映了搜索是否具有粘性（ 仅从正则表达式的 lastIndex 属性表示的索引处搜索 ）。sticky 是正则表达式对象的只读属性。"><code>RegExp.prototype.sticky</code></a> <span title="这是一个实验性的 API，请尽量不要在生产环境中使用它。"><i class="icon-beaker"> </i></span></dt>
<dd>
  是否开启粘滞匹配。</dd>
</dl>
<div>
<div class="blockIndicator inheritsbox template-jsOverrides">
<div><span style="font-weight: 700;">Properties inherited from <a href="https://developer.mozilla.orgReference/Global_Objects/Object"><code>Object</code></a>:</span></div>
<div><a class="internal" href="https://developer.mozilla.orgReference/Global_Objects/Object/Parent"><code>__parent__</code></a>, <a class="internal" href="https://developer.mozilla.orgReference/Global_Objects/Object/Proto"><code>__proto__</code></a></div>
</div></div>
<h2 id="Methods" name="Methods">方法</h2>
<p>查看<a class="new" href="/zh-CN/docs/JavaScript/Reference/Deprecated_Features#RegExp_Methods" rel="nofollow" title="zh-CN/docs/JavaScript/Reference/Deprecated_Features#RegExp_Methods">已废弃的RegExp方法</a></p>
<dl>
<dt>
<a href="Reference/Global_Objects/RegExp/exec" title="exec() 方法在一个指定字符串中执行一个搜索匹配。返回一个结果数组或 null。"><code>RegExp.prototype.exec()</code></a></dt>
<dd>
  在目标字符串中执行一次正则匹配操作。</dd>
<dt>
<a href="Reference/Global_Objects/RegExp/test" title="test() 方法执行一个检索，用来查看正则表达式与指定的字符串是否匹配。返回 true 或 false。"><code>RegExp.prototype.test()</code></a></dt>
<dd>
  测试当前正则是否能匹配目标字符串。</dd>
<dt>
<a href="Reference/Global_Objects/RegExp/toSource" title="返回一个字符串,代表当前对象的源代码"><code>RegExp.prototype.toSource()</code></a> <span class="icon-only-inline" title="This API has not been standardized."><i class="icon-warning-sign"> </i></span></dt>
<dd>
  返回一个字符串，其值为该正则对象的字面量形式。覆盖了<code>Object.prototype.toSource</code> 方法.</dd>
<dt>
<a href="Reference/Global_Objects/RegExp/toString" title="toString() 返回一个表示该正则表达式的字符串。"><code>RegExp.prototype.toString()</code></a></dt>
<dd>
  返回一个字符串，其值为该正则对象的字面量形式。覆盖了<a href="Reference/Global_Objects/Object/toString" title="toString() 方法返回一个表示该对象的字符串。"><code>Object.prototype.toString()</code></a> 方法。</dd>
</dl>
<div>
<div class="blockIndicator inheritsbox template-jsOverrides">
<div><span style="font-weight: 700;">Methods inherited from <a href="https://developer.mozilla.orgReference/Global_Objects/Object"><code>Object</code></a>:</span></div>
<div><a class="internal new" href="https://developer.mozilla.orgReference/Global_Objects/Object/DefineGetter" rel="nofollow"><code>__defineGetter__</code></a>, <a class="internal new" href="https://developer.mozilla.orgReference/Global_Objects/Object/DefineSetter" rel="nofollow"><code>__defineSetter__</code></a>, <a class="internal" href="https://developer.mozilla.orgReference/Global_Objects/Object/HasOwnProperty"><code>hasOwnProperty</code></a>, <a class="internal" href="https://developer.mozilla.orgReference/Global_Objects/Object/IsPrototypeOf"><code>isPrototypeOf</code></a>, <a class="internal" href="https://developer.mozilla.orgReference/Global_Objects/Object/LookupGetter"><code>__lookupGetter__</code></a>, <a class="internal new" href="https://developer.mozilla.orgReference/Global_Objects/Object/LookupSetter" rel="nofollow"><code>__lookupSetter__</code></a>, <a class="internal" href="https://developer.mozilla.orgReference/Global_Objects/Object/NoSuchMethod"><code>__noSuchMethod__</code></a>, <a class="internal" href="https://developer.mozilla.orgReference/Global_Objects/Object/PropertyIsEnumerable"><code>propertyIsEnumerable</code></a>, <a class="internal" href="https://developer.mozilla.orgReference/Global_Objects/Object/ToLocaleString"><code>toLocaleString</code></a>, <a class="internal" href="https://developer.mozilla.orgReference/Global_Objects/Object/Unwatch"><code>unwatch</code></a>, <a class="internal" href="https://developer.mozilla.orgReference/Global_Objects/Object/ValueOf"><code>valueOf</code></a>, <a class="internal" href="https://developer.mozilla.orgReference/Global_Objects/Object/Watch"><code>watch</code></a></div>
</div></div>
<h2 id="规范" style="margin-bottom: 20px; line-height: 30px;">规范</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
<tr>
<td>ECMAScript 1st Edition. Implemented in JavaScript 1.1</td>
<td>Standard</td>
<td>Initial definition.</td>
</tr>
<tr>
<td><a class="external" href="https://www.ecma-international.org/ecma-262/5.1/#sec-15.10.5.1" hreflang="en" lang="en" rel="noopener">ECMAScript 5.1 (ECMA-262)<br/><small lang="zh-CN">RegExp</small></a></td>
<td><span class="spec-Standard">Standard</span></td>
<td> </td>
</tr>
<tr>
<td><a class="external" href="https://www.ecma-international.org/ecma-262/6.0/#sec-regexp.prototype" hreflang="en" lang="en" rel="noopener">ECMAScript 2015 (6th Edition, ECMA-262)<br/><small lang="zh-CN">RegExp.prototype</small></a></td>
<td><span class="spec-Standard">Standard</span></td>
<td> </td>
</tr>
</tbody>
</table>
<h2 id="浏览器兼容性" style="margin-bottom: 20px; line-height: 30px;">浏览器兼容性</h2>
<p></p><div class="blockIndicator warning"><strong><a class="external" href="https://github.com/mdn/browser-compat-data" rel="noopener">We're converting our compatibility data into a machine-readable JSON format</a></strong>.
            This compatibility table still uses the old format,
            because we haven't yet converted the data it contains.
            <strong><a class="new" href="/zh-CN/docs/MDN/Contribute/Structures/Compatibility_tables" rel="nofollow">Find out how you can help!</a></strong></div>
<div class="htab">
<a id="AutoCompatibilityTable" name="AutoCompatibilityTable"></a>
<ul>
<li class="selected"><a>Desktop</a></li>
<li><a>Mobile</a></li>
</ul>
</div><p></p>
<div id="compat-desktop">
<table class="compat-table">
<tbody>
<tr>
<th style="line-height: 16px;">Feature</th>
<th style="line-height: 16px;">Chrome</th>
<th style="line-height: 16px;">Firefox (Gecko)</th>
<th style="line-height: 16px;">Internet Explorer</th>
<th style="line-height: 16px;">Opera</th>
<th style="line-height: 16px;">Safari</th>
</tr>
<tr>
<td>Basic support</td>
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
</tr>
</tbody>
</table>
</div>
<div id="compat-mobile">
<table class="compat-table">
<tbody>
<tr>
<th style="line-height: 16px;">Feature</th>
<th style="line-height: 16px;">Android</th>
<th style="line-height: 16px;">Chrome for Android</th>
<th style="line-height: 16px;">Firefox Mobile (Gecko)</th>
<th style="line-height: 16px;">IE Mobile</th>
<th style="line-height: 16px;">Opera Mobile</th>
<th style="line-height: 16px;">Safari Mobile</th>
</tr>
<tr>
<td>Basic support</td>
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
</tr>
</tbody>
</table>
</div>
<h2 id="相关链接" style="margin-bottom: 20px; line-height: 30px;">相关链接</h2>
<ul>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions" title="JavaScript/Guide/Regular_Expressions">Regular Expressions</a> chapter in the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide" title="JavaScript/Guide">JavaScript Guide</a></li>
<li><a href="Reference/Global_Objects/RegExp" title="RegExp 构造函数创建了一个正则表达式对象，用于将文本与一个模式匹配。"><code>RegExp</code></a></li>
<li><a href="Reference/Global_Objects/Function/prototype" title="Function.prototype 属性存储了 Function 的原型对象。"><code>Function.prototype</code></a></li>
</ul>
<p> </p>
</article>